<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-02-03 19:18:26
 * @Last Modified time: 2023-02-03 19:36:11
 */
namespace app\api\controller\store;	
use think\facade\App;
use app\common\services\store\GoodsCateService;
use frank\utils\helper\ArrayHelper;

/**
 * Class GoodsCate
 */
class GoodsCate extends \app\api\controller\Base
{ 	
    /**
     * GoodsCateService constructor.
     * @param App $app
     */
    public function __construct(App $app,GoodsCateService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    /**
     * 获取商品分类
     * @force(false)
     * @method(GET)
     */
    public function index(){
        $layout = sysconf('store_diy_categroy');
        $data = $this->service->getAll();
        $isTree = ['2_1','2_2','2_3','3_1','3_2','3_3'];
        if(in_array($layout, $isTree)){
        	$data = ArrayHelper::arr2tree($data,"id");
        }
        $this->success('获取成功',$data);
    }

}